import os
import json
import serial

com_prot = "COM15"
com_baul = 9600

cur_dir = os.getcwd()
f = open("config.json")
json_str = f.read()

check_sum = 0
for ch in json_str:
    check_sum +=ord(ch)

print("json string: %s"%json_str)
#print("checksum:%d"%check_sum)

json_dict = json.loads(json_str)
json_dict["checksum"] = check_sum

json_str = json.dumps(json_dict)
print(json_str)

COM = serial.Serial(com_prot,com_baul)
COM.write(bytes(json_str,"utf-8"))
COM.write(bytes("\n","utf-8"))


